﻿using System;
using UnityEngine;

namespace EditorExtensions
{
    public class GUIAPI
    {
        private Rect mLabelRect = new Rect(0, 60, 200, 20);
        private Rect mTextRect = new Rect(20, 90, 200, 20);
        private Rect mTextAreaRect = new Rect(20, 120, 200, 100);
        private Rect mPassWordFieldRect = new Rect(20, 250, 200, 20);
        private Rect mButtonRect = new Rect(20, 270, 200, 20);
        private Rect mRepeatButtonRect = new Rect(20, 290, 200, 20);
        private Rect mToggleRect = new Rect(20, 320, 200, 20);
        private Rect mToolbarRect = new Rect(20, 350, 200, 20);
        private Rect mBoxRect = new Rect(20, 380, 100, 100);
        private Rect mHorizontalSliderRect = new Rect(20, 500, 100, 20);
        private Rect mVerticalSliderRect = new Rect(20, 580, 20, 100);
        private Rect mGroupRect = new Rect(20, 700, 100, 20);
        private Rect mWindowRect = new Rect(20, 750, 100, 20);
        private string mTextFieldValue;
        private string mTextAreaValue;
        private string mPassWordFieldValue = String.Empty;
        private bool mToggleValue;
        private int mToolbarIndex;
        private float mSliderValue;

        public void Draw()
        {
            GUI.Label(mLabelRect, "Label: Hello GUIApi");
            mTextFieldValue = GUI.TextField(mTextRect, mTextFieldValue);
            mTextAreaValue = GUI.TextArea(mTextAreaRect, mTextAreaValue);
            mPassWordFieldValue = GUI.PasswordField(mPassWordFieldRect, mPassWordFieldValue, '$');
            if (GUI.Button(mButtonRect, "Button"))
            {
                Debug.Log("Button Clicked");
            }

            if (GUI.RepeatButton(mRepeatButtonRect, "RepeatButton"))
            {
                Debug.Log("RepeatButton Clicked");
            }

            if (GUI.Toggle(mToggleRect, mToggleValue, "Toggle"))
            {
                Debug.Log("Toggle Clicked");
            }

            mToolbarIndex = GUI.Toolbar(mToolbarRect, mToolbarIndex, new string[]
            {
                "1", "2", "3"
            });
            GUI.Box(mBoxRect, "Box");

            mSliderValue = GUI.HorizontalSlider(mHorizontalSliderRect, mSliderValue, 0, 1);
            mSliderValue = GUI.VerticalSlider(mVerticalSliderRect, mSliderValue, 0, 1);

            GUI.BeginGroup(mGroupRect, "Group");
            GUI.EndGroup();
            GUI.Window(11111, mWindowRect, (rect) =>
            {
            }, "窗口");
        }
    }
}